home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / QuickDraw / Restore Screen Cluts / ColorReset.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-15  |  12.9 KB  |  348 lines  |  [TEXT/MPS ]

  1. #ifndef __CLASSICIMAGE__
  2. #define __CLASSICIMAGE__
  3. /******************************************************************************\
  4. *
  5. * Apple Macintosh Developer Technical Support
  6. *
  7. * Main header file for the ClassicImage application
  8. *
  9. * Program: WorldImage
  10. * File:    WorldImage.h
  11. *
  12. * by:      Forrest Tanaka
  13. *
  14. * Copyright © 1988-1991 Apple Computer, Inc.
  15. * All rights reserved.
  16. *
  17. \******************************************************************************/
  18.     
  19.  
  20. /******************************************************************************\
  21. * Header Files
  22. \******************************************************************************/
  23.  
  24. #ifndef __STANDARDFILE__
  25. #include <StandardFile.h>
  26. #endif
  27.  
  28. #ifndef __WINDOWS__
  29. #include <Windows.h>
  30. #endif
  31.  
  32.  
  33. /******************************************************************************\
  34. * Constants
  35. \******************************************************************************/
  36.  
  37. #define kScrollBarWidth 16 /* Number of pixels wide a scroll bar is */
  38.  
  39. /* Alert types */
  40. #define kGenericAlert 0 /* Display a generic alert */
  41. #define kNoteAlert    1 /* Display the note alert */
  42. #define kCautionAlert 2 /* Display the caution alert */
  43. #define kStopAlert    3 /* Display the stop alert */
  44.  
  45. /* Alert button options */
  46. #define rOKAlertID       6010 /* Resource ID of OK alert */
  47. #define rOKCancelAlertID 6011 /* Resource ID of OK/Cancel alert */
  48. #define rSaveAlertID     6012 /* Resource ID of Save/Cancel/Don’t Save alert */
  49.  
  50. /* Button item numbers */
  51. #define kSaveButton       1 /* Item number of Save button */
  52. #define kCancelSaveButton 2 /* Item number of Cancel button for saves */
  53. #define kDontSaveButton   3 /* Item number of Don’t Save button */
  54.  
  55. /* Memory error message constants */
  56. #define rMemErrMessages    1000 /* Resource ID of memory error msg STR# */
  57. #define kMemErrAppOpenMsg  1    /* Not enough memory to open application */
  58. #define kMemErrOpenDocMsg  2    /* Not enough memory to open a document */
  59.  
  60. /* Resource error message constants */
  61. #define rResErrMessages     1001 /* Resource ID of resource err message STR# */
  62. #define kResErrAppDamageMsg 1    /* Application is damaged */
  63.  
  64. /* Miscellaneous error message constants */
  65. #define rMiscErrMessages   1002 /* Resource ID of misc. error message STR# */
  66. #define kMiscErrUnknownMsg 1    /* Unknown error */
  67. #define kMiscErrNoQTMsg    2    /* QuickTime not available */
  68. #define kMiscQuickTimeMsg  3    /* Some sort of QuickTime error */
  69.  
  70. /* File error message constants */
  71. #define rFileErrMessages   1003 /* Resource ID of file error message STR# */
  72. #define kFileErrDocOpenMsg 1    /* Document is already open elsewhere */
  73.  
  74.  
  75. /******************************************************************************\
  76. * Macros
  77. \******************************************************************************/
  78.  
  79. #ifdef applec
  80. #define topLeft(r) (*((Point *) &(r).top))
  81. #define botRight(r) (*((Point *) &(r).bottom))
  82. #define thePort qd.thePort
  83. #endif
  84.  
  85. #define hiWord(a) ((short) (((unsigned long) a) >> 16L))
  86. #define loWord(a) ((short) ((unsigned long) a))
  87.  
  88.  
  89. /******************************************************************************\
  90. * Global Variables
  91. \******************************************************************************/
  92.  
  93. extern Boolean gQuitting;            /* True if user requested that app quit */
  94. extern Boolean gWereInFront;         /* True if this application is frontmost */
  95. extern Boolean gFixMenus;            /* True if menus need fixing */
  96. extern Boolean gHasAppleEvents;      /* True if Apple Events implemented */
  97. extern Boolean gHasCoolSF;           /* True if 7.0 Standard File available */
  98.  
  99.  
  100. /******************************************************************************\
  101. * DoQuit - Handle Quit request from the user
  102. *
  103. * When the user requests that this application should quit, DoQuit is called to
  104. * perform the Quit command.  All open document windows and desk accessory
  105. * windows (only applicable before system software version 7.0) are closed and
  106. * the gQuitting global variable is set to true.
  107. \******************************************************************************/
  108.  
  109. void DoQuit(void);
  110.  
  111.  
  112. /******************************************************************************\
  113. * IsDAWindow - Test to see whether a window belongs to a DA or not
  114. *
  115. * If the window specified by aWindow belongs to a desk accessory, then
  116. * IsDAWindow returns true, otherwise it returns false.  If aWindow is nil, then
  117. * IsDAWindow returns false.
  118. \******************************************************************************/
  119.  
  120. Boolean IsDAWindow(
  121.     WindowPtr aWindow);
  122.  
  123.  
  124. /******************************************************************************\
  125. * DoUpdateEvt - Handle an update event for any window
  126. *
  127. * When an update event is received, DoUpdateEvt is called to handle the
  128. * redrawing of the window that caused the update event.  DoUpdateEvt determines
  129. * the kind of window that needs updating and calls the routine that handles that
  130. * kind of window to draw it.  The anEvent parameter contains the update event.
  131. \******************************************************************************/
  132.  
  133. void DoUpdateEvt(
  134.     EventRecord *anEvent);
  135.  
  136.  
  137. /******************************************************************************\
  138. * DoActivateEvt - Handle an activate event for any window
  139. *
  140. * DoActivateEvt is called when an active event is received for the window
  141. * specified by eventWind.  becomingActive is TRUE if the window is becoming
  142. * activated.  It’s FALSE if the window is becoming inactive.
  143. \******************************************************************************/
  144.  
  145. void DoActivateEvt(
  146.     WindowPtr eventWindow,
  147.     Boolean   becomingActive);
  148.  
  149.  
  150. /******************************************************************************\
  151. * ShowAlert - Show an alert
  152. *
  153. * This routine puts up a an alert with a specified message.  alertType specifies
  154. * which kind of icon to display in the upper-left corner of the alert.
  155. * kGenericAlert specifies that no icon should be displayed.  kNoteAlert
  156. * specifies that the note icon should be displayed.  kCautionAlert specifies
  157. * that the caution icon should be displayed.  kStopAlert specifies that the stop
  158. * icon should be displayed.
  159. *
  160. * buttonOption specifies what buttons should be offered.  rOKAlertID specifies
  161. * that only an OK button should be offered.  rOKCancelAlertID specifies that
  162. * both an OK and a Cancel button should be offered.
  163. *
  164. * messageClass specifies the STR# resource ID which contains the message to
  165. * display and messageIndex specifies the index (the first message is index 1)
  166. * into that STR# of the message to display.
  167. *
  168. * The alert window is placed into alert position on the screen containing most
  169. * of the window specified by parentWindow, or the main screen if parentWindow is
  170. * nil.
  171. \******************************************************************************/
  172.  
  173. short ShowAlert(
  174.     short alertType,
  175.     short buttonOption,
  176.     short messageClass,
  177.     short messageIndex);
  178.  
  179.  
  180. /******************************************************************************\
  181. * TrapExists - Determine whether a trap is implemented
  182. *
  183. * If the trap specified by theTrap is implemented, then TrapExists returns true.
  184. * Otherwise, false is returned.
  185. \******************************************************************************/
  186.  
  187. Boolean TrapExists(
  188.     short theTrap);
  189.  
  190.  
  191. /******************************************************************************\
  192. * FileSpecGet
  193. *
  194. \******************************************************************************/
  195.  
  196. Boolean FileSpecGet(
  197.     FileFilterProcPtr fileFilter,
  198.     short             numTypes,
  199.     SFTypeList        typeList,
  200.     StandardFileReply *retReply);
  201.  
  202.  
  203. /******************************************************************************\
  204. * ConvertOldToNewSFReply - Convert old SFReply record to new StandardFileReply record
  205. *
  206. * The old SFReply record passed in oldReply is converted to the new
  207. * StandardFileReply record that was introduced with system software version 7.0.
  208. * The resulting StandardFileReply record is returned in the newReply parameter.
  209. * If any errors occur, the error code is returned and newReply is untouched.
  210. *
  211. * The following conversions are done:
  212. *
  213. * StandardFileReply            SFReply
  214. * -----------------            -------
  215. * Boolean    sfGood        <-  Boolean good
  216. * Boolean    sfReplacing   <-  true if file exists, false if not
  217. * OSType     sfType        <-  OSType  fType
  218. * FSSpec     sfFile 
  219. *     vRefNum;             <-  real vRefnum from (short vRefNum)
  220. *     parID;               <-  real dirID from (short vRefNum)
  221. *     name;                <-  Str63   fName
  222. * ScriptCode sfScript      <-  iuSystemScript
  223. * short      sfFlags       <-  0
  224. * Boolean    sfIsFolder    <-  false
  225. * Boolean    sfIsVolume    <-  false
  226. * long       sfReserved1   <-  0
  227. * short      sfReserved2   <-  0
  228. *
  229. * The setting of sfScript to iuSystemScript I believe is incorrect, but I also
  230. * believe that it’s the best that can be done.  There’s no reliable way to tell
  231. * which script a user was using when he or she typed in the file name in the
  232. * Standard File dialog.  So, GUESS!
  233. \******************************************************************************/
  234.  
  235. OSErr ConvertOldToNewSFReply(
  236.     SFReply           *oldReply,
  237.     StandardFileReply *newReply);
  238.  
  239.  
  240. /******************************************************************************\
  241. * EqualFSSpec - Check equality of FSSpec records
  242. *
  243. * EqualFSSpec returns TRUE if the file specified by spec1 refers to the same
  244. * file as the one specified by spec2.  Otherwise, EqualFSSpec returns FALSE.
  245. \******************************************************************************/
  246.  
  247. Boolean EqualFSSpec(
  248.     FSSpecPtr spec0,
  249.     FSSpecPtr spec1);
  250.  
  251.  
  252. /******************************************************************************\
  253. * CmdPeriodEvent - Detect whether an event is a command-period
  254. *
  255. * This routine determines whether the event passed in anEvent was caused by the
  256. * user typing command-period.  If it was, then true is returned, otherwise false
  257. * is returned.
  258. \******************************************************************************/
  259.  
  260. Boolean CmdPeriodEvent(
  261.     EventRecord *anEvent);
  262.  
  263.  
  264. /******************************************************************************\
  265. * FakeButtonHit - Visually simulate the click of a button
  266. *
  267. * This routine is used to hilight a button for one-tenth of a second to visually
  268. * simulate the click of the mouse on the button passed in the buttonControl
  269. * parameter.  This is normally used when the Enter or Return key is pressed when
  270. * a dialog box is up.  The default button must be momentarily hilighted to show
  271. * the user what he or she actually did.
  272. \******************************************************************************/
  273.  
  274. void FakeButtonHit(
  275.     ControlHandle buttonControl);
  276.  
  277.  
  278. /******************************************************************************\
  279. * Public: CreateGrafPort
  280. *
  281. * Most of this code is very similar to the code in Macintosh Technical Note #41
  282. * “Drawing Into an Off-Screen BitMap.
  283. \******************************************************************************/
  284.  
  285. GrafPtr CreateGrafPort(
  286.     Rect *bounds);
  287.  
  288.  
  289. /******************************************************************************\
  290. * DisposeGrafPort
  291. *
  292. * DisposeGrafPort disposes of the GrafPort specified by doomedPort.  The visRgn,
  293. * clipRgn, bit image, and the GrafPort structure itself must all be disposed of.
  294. * ClosePort is called to dispose of the visRgn and clipRgn.  The bit image and
  295. * GrafPort itself are normal non-relocatable blocks of memory, so they’re just
  296. * disposed of through DisposPtr.
  297. \******************************************************************************/
  298.  
  299. void DisposeGrafPort(
  300.     GrafPtr doomedPort);
  301.  
  302.  
  303. /******************************************************************************\
  304. * NAME & SYNOPSIS:
  305. * RestoreColorsPalette: Restore all screens to the default color table
  306. *
  307. * PARAMETERS:
  308. * None
  309. *
  310. * DEFINITION:
  311. * RestoreColorsPalette sets the color tables of all screens to the default
  312. * colors by using the Palette Manager.  Direct-color screens and screens which
  313. * already have the default set of colors are unaffected.  It’s assumed that
  314. * Color QuickDraw is available, and 32-Bit QuickDraw 1.0 and/or system software
  315. * version 6.0.5 and beyond is available.
  316. *
  317. * RETURN VALUES:
  318. * None
  319. \******************************************************************************/
  320.  
  321. void RestoreColorsPalette(void);
  322.  
  323.  
  324. /******************************************************************************\
  325. * NAME & SYNOPSIS:
  326. * RestoreColorsSlam: Restore all screens to the default color table
  327. *
  328. * PARAMETERS:
  329. * None
  330. *
  331. * DEFINITION:
  332. * RestoreColorsSlam sets the color tables of all screens to the default colors
  333. * by using low-level calls.  All screens are redrawn when this routine is
  334. * called.  Also, if the color table has been changed and then RestoreColorsSlam
  335. * is called to reset them, all screens are still redrawn when the application
  336. * quits.  It’s assumed that Color QuickDraw is available, and 32-Bit QuickDraw
  337. * 1.0 and/or system software version 6.0.5 and beyond is available.
  338. *
  339. * RETURN VALUES:
  340. * None
  341. \******************************************************************************/
  342.  
  343. void RestoreColorsSlam(void);
  344.  
  345.  
  346. #endif
  347.